/**
 * 上拉加载的mixin
 * */
import {isLastPage, showLoading} from "../utils/jk-utils";
export default {
	data() {
		return {
			isNoMore: false,
			tableData: []
		};
	},
	methods: {
		transferDataItem(e) {
			return e;
		},
		getMore() {
			if (!isLastPage(this.searchParams.totalCount, this.searchParams.pageNo, this.searchParams.pageSize)) {
				this.searchParams.pageNo++;
				showLoading(true);
				return this.apiConfig['list'](this.searchParams).then(res => {
					showLoading(false);
					if (res.data.status === 200) {
						this.$set(this.searchParams, 'totalCount', res.data.count);
						if (res.data.res && res.data.res.length) {
							res.data.res.forEach(x => {
								this.tableData.push(this.transferDataItem(x));
							})
						}

					}
				})
			} else {
				// wx.showToast({ title: '没有更多了!', icon: 'error', duration: 500 })
				this.isNoMore = true;
			}
		},
	}
}
